package com.example.testapplication.ui.login;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;

import com.example.testapplication.R;
import com.example.testapplication.other.KeyboardWatcher;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.binding.command.BindingConsumer;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;

public class LoginFragmentViewModel extends BaseViewModel {
    public LoginFragmentViewModel(@NonNull Application application) {
        super(application);
    }

    //用户名的绑定
    public ObservableField<String> userName = new ObservableField<>("");
//    public MutableLiveData<String> userName = new MutableLiveData<>("");
    //密码的绑定
    public ObservableField<String> password = new ObservableField<>("");

    //封装一个界面发生改变的观察者
    public UIChangeObservable uc = new UIChangeObservable();



    public class UIChangeObservable {
        //点击事件观察者
        public SingleLiveEvent<Integer> pClickEvent = new SingleLiveEvent<>();
    }

    //titleBar右边的点击事件
    public BindingCommand onTitleBarRightCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            uc.pClickEvent.setValue(1);

        }
    });

    //忘记密码点击事件
    public BindingCommand onClickForgetCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            uc.pClickEvent.setValue(2);

        }
    });


    //登录点击事件
    public BindingCommand onClickLoginCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            uc.pClickEvent.setValue(3);
        }
    });

}
